//
//  HomeViewController.m
//  诚诚直播
//
//  Created by 廖易诚 on 16/7/8.
//  Copyright © 2016年 liaoyicheng. All rights reserved.
//

#import "HomeViewController.h"

@interface HomeViewController ()

@end

@implementation HomeViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.view.backgroundColor = [UIColor redColor];
    
    
    
    [self setupNav];
}

#pragma mark -  设置导航栏

- (void)setupNav {
    
    [self.navigationController.navigationBar setTintColor:[UIColor whiteColor]];
    
    // titleView
    UIView *navView = [[UIView alloc] initWithFrame:self.navigationController.navigationBar.bounds];
    navView.hm_width = [UIScreen hm_screenWidth] - 150;
    navView.backgroundColor = [UIColor clearColor];
    self.navigationItem.titleView = navView;
    
    CGFloat width = navView.hm_width / 3;
    CGFloat height = navView.hm_height;
    for (int i = 0; i < 3; i++) {
        UIButton *btn = [[UIButton alloc] initWithFrame:CGRectMake(width * i, 0, width, height)];
        [navView addSubview:btn];
        
        switch (i) {
            case 0:
                [btn setTitle:@"热门" forState:UIControlStateNormal];
                break;
            case 1:
                [btn setTitle:@"最新" forState:UIControlStateNormal];
                break;
            case 2:
                [btn setTitle:@"关注" forState:UIControlStateNormal];
                break;
                
            default:
                break;
        }
        
    }
    
    // 左边放大镜
    self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:@"search_15x14"] style:UIBarButtonItemStylePlain target:self action:@selector(searchUser)];
    // 右边皇冠
    self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:@"head_crown_24x24"] style:UIBarButtonItemStylePlain target:self action:@selector(rightItemClick)];
}

#pragma mark - 点击放大镜搜索
- (void)searchUser {
    NSLog(@"搜索用户名");
}

#pragma mark - 点击皇冠
- (void)rightItemClick {
    NSLog(@"点击了右边的皇冠");
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
